﻿using System;

namespace AgFractal.Fractals
{
    public class PhoenixMandelbrot : AbstractFractal
    {
        public PhoenixMandelbrot()
        {
            Name = Description = "Phoenix mandelbrot";
            ID = new Guid("F43CEC7F-35E2-4d87-A05E-DA4E77000587");
            R1 = -2.25; I1 = 1.5; R2 = 2.25; I2 = -1.5;
        }
        protected override short Calculate(double r, double i, short MaxIteration)
        {
            short j;
            Complex z = new Complex(r, i);
            Complex c = z;
            Complex y = new Complex();
            Complex t;
            for (j = 0; j < MaxIteration; j++)
            {
                t = z * z + c + 0.5 * y;
                y = z;
                z = t;
                if (z.Abs2() >= 1e20) break;
            }
            return j;
        }
    }
}
